package com.Test;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest {
    ClassPathXmlApplicationContext applicationContext;
    @Before
    public void before() {
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
    }
    @After
    public void after() {
        applicationContext.close();
    }
    @Test
    public void u1(){
        Object u1 = applicationContext.getBean("u1");
        System.out.println(u1);
    }
    @Test
    public void role(){
        Object role = applicationContext.getBean("role");
        System.out.println(role);
    }
    @Test
    public void p1(){
        Object p1 = applicationContext.getBean("p1");
        System.out.println(p1);
    }

    @Test
    public void scope(){
        Object u1 = applicationContext.getBean("u1");
        Object u2 = applicationContext.getBean("u1");
        Object u3 = applicationContext.getBean("u1");
        System.out.println(u1.hashCode());
        System.out.println(u2.hashCode());
        System.out.println(u3.hashCode());
    }

    @Test
    public void live(){
        System.out.println("生命周期方法测试");
    }
}
